<template>
  <div>
      <el-button v-if="ButtonConfig['reset']" type="warning" circle icon="el-icon-refresh" @click="reset"/>
      <el-button v-if="ButtonConfig['query']" circle icon="el-icon-search" @click="query"/>
      <el-button v-has-permission="ButtonConfig['add'].permission === undefined ? [] : ButtonConfig['add'].permission" v-if="ButtonConfig['add']" type="primary" icon="el-icon-plus" circle @click="add"/>
      <el-button v-has-permission="ButtonConfig['edit'].permission === undefined ? [] : ButtonConfig['edit'].permission" v-if="ButtonConfig['edit']" type="info" icon="el-icon-edit" circle @click="edit"/>
      <el-button v-has-permission="ButtonConfig['delete'].permission === undefined ? [] : ButtonConfig['delete'].permission" v-if="ButtonConfig['delete']" type="danger" icon="el-icon-delete" circle @click="del"/>
<!--
    <el-tooltip class="item" effect="light" :content="ButtonConfig['reset'].btnTip" placement="top">
      <el-button v-if="ButtonConfig['reset']" type="warning" circle icon="el-icon-refresh" @click="reset"/>
    </el-tooltip>
    <el-tooltip class="item" effect="light" :content="ButtonConfig['query'].btnTip" placement="top">
      <el-button v-if="ButtonConfig['query']" circle icon="el-icon-search" @click="query"/>
    </el-tooltip>
    <el-tooltip class="item" effect="light" :content="ButtonConfig['add'].btnTip" placement="top">
      <el-button v-if="ButtonConfig['add']" type="primary" icon="el-icon-plus" circle @click="add"/>
    </el-tooltip>
    <el-tooltip class="item" effect="light" :content="ButtonConfig['edit'].btnTip" placement="top">
      <el-button v-if="ButtonConfig['edit']" type="info" icon="el-icon-edit" circle @click="edit"/>
    </el-tooltip>
    <el-tooltip class="item" effect="light" :content="ButtonConfig['delete'].btnTip" placement="top">
      <el-button v-if="ButtonConfig['delete']" type="danger" icon="el-icon-delete" circle @click="del"/>
    </el-tooltip>
-->
  </div>
</template>

<script>
export default {
  name: "ButtonGroup",
  props: {
    ButtonConfig: {
      type: Object,
      required: true
    },
    selectRow: null
  },
  methods: {
    reset() {
      this.$emit(this.ButtonConfig['reset'].clickCall)
    },
    query() {
      this.$emit(this.ButtonConfig['query'].clickCall)
    },
    add() {
      this.$emit(this.ButtonConfig['add'].clickCall,'1')
    },
    edit() {
      if (!this.selectRow) {
        this.$message.warning('请先选择一行记录！')
        return
      }
      this.$emit(this.ButtonConfig['edit'].clickCall,'0')
    },
    del() {
      if (!this.selectRow) {
        this.$message.warning('请先选择一行记录！')
        return
      }
      this.$emit(this.ButtonConfig['delete'].clickCall,this.selectRow)
    }
  }
}
</script>

<style scoped>

</style>